<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="PersonalPage.css" />
</head>
<%@page import="entities.*"%>
<%@page import="java.util.*"%>
<%
	RegisteredUser user = (RegisteredUser) request.getSession()
			.getAttribute("user");
	List<PendingFriendship> pendingFriendship = (List<PendingFriendship>) request.getSession().getAttribute("pendingfriendships");
	List<HelpRequest> helpRequests = (List<HelpRequest>) request.getSession().getAttribute("helprequests");
	List<AskForAdding> abilityRequests = (List<AskForAdding>) request.getSession().getAttribute("abilityrequests");
	
%>
<body style="background-color: #94C0D6">
	<img alt="" src="Swim.jpg" style="height: 64px; width: 200px;">
	<form
		style="background-color: #A6B0DB; border-bottom-width: thin; border-right-width: thin; border-left-width: thin; border-top-width: thin; border-top-color: #8080FF; border-right-color: #8080FF; border-top-style: solid; border-right-style: solid; height: 24px;">
		<a href="SearchServlet">Back.</a> <a href="LogOutServlet">Logout.</a>
	</form>
<form style="width: 453px; background-color: #8080FF; height: 22px; vertical-align: middle; border-top-style: solid; border-top-color: #8080C0; border-right-color: #8080C0; border-right-width: thin; border-right-style: solid; border-top-width: thin">
			<center><b><%
				out.print(user.getSurname() + " " + user.getName() + " (alias "
						+ user.getUserId() + ")");
			%></b></center>
</form>
<br>
<br>
<br>
<fieldset style="width: 995px; background-color: #A6B0DB">
		<div class=field style="width: 276px;">
			<form style="height: 164px; width: 183px; background-color: #A6B0DB; border-top-style: solid; border-top-color: #8080FF; border-right-color: #8080FF; border-right-style: none; border-left-color: #8080FF; border-left-style: solid; border-left-width: thin; border-bottom-color: #8080FF; border-top-width: thin">

				<a href="UpdatePersonalInformation.jsp"><br> Edit Personal Info <br></a> 
					<a href="NotificationServlet">View Notifications <br> </a> 
					<a href="SuggestionsServlet">View Friend Suggestions <br></a> 
					<a href="PendingFriendshipServlet">View Friendship Requests <br></a>
				<a href="PendingHelpServlet">View Help Requests <br></a>
								<a href="RequestAbilityServlet">Request New Ability <br></a>
			</form>
		</div>
		<div class="field" style="width: 276px;">
			<b>Notification</b>
			<form class="form-inside"
				style="width: 955px; height: 222px; list-style-type: disc" action="">
				<br>
				<table border="1" cellspacing="0" cellpadding="5" style="background-color: #8080C0">
					<%
						for (PendingFriendship p : pendingFriendship) {
							out.println("<tr><td>");
							out.println(p.getKey().getReceiver().getName() + " " + p.getKey().getReceiver().getSurname() 
									+ " (" + p.getKey().getReceiver().getUserId() + ")" + " is now your friend!</td></tr>");
						}
						for (HelpRequest h  : helpRequests) {
							out.println("<tr><td>");
							if(h.getAnswer()){
								out.println("<a href=\"ProfileServlet?user=" + h.getReceiver().getUserId() + "\">");
							}
							out.println(h.getReceiver().getName() + " " + h.getReceiver().getSurname() + " (" + h.getReceiver().getUserId() + ")" 
							+ " has " + (h.getAnswer() ? "accepted" : "refused") + " your help request concerning ability " 
							+ h.getAbility().getName() + " sent on " + h.getDate() + "");
							if(h.getAnswer()){
								out.println("</a></td></tr>");
							} else {
								out.println("</td></tr>");
							}
						}
						for (AskForAdding h  : abilityRequests) {
							out.println("<tr><td>");
							out.println("Ability " + h.getKey().getAbilityName() + " that you requested can now be added to your ability list.</td></tr>");
						}
					%>
				</table>
			</form>
		</div>
	</fieldset>
</body>
</html>

